package sg.edu.nus.dashboard.advisor.control.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	import sg.edu.nus.dashboard.advisor.control.business.UpdateAdviceDelegate;
	import sg.edu.nus.dashboard.advisor.control.event.GetAdviceEvent;
	import sg.edu.nus.dashboard.advisor.control.event.UpdateAdviceEvent;
	import sg.edu.nus.dashboard.main.model.AppModelLocator;
	
	public class UpdateAdviceCommand implements ICommand, IResponder
	{
		private var model:AppModelLocator = AppModelLocator.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
			var d:UpdateAdviceDelegate = new UpdateAdviceDelegate(this);
			var e:UpdateAdviceEvent = UpdateAdviceEvent(event);
			
			d.updateAdviceByGroup(e.list);
		}
		
		public function result(data:Object):void
		{
			model.advisor.adviceTempArr.removeAll();
		}
		
		public function fault(info:Object):void
		{
		}
	}
}